package com.site.wisdom_construction.controller.iotModule;

import com.alibaba.fastjson.JSONObject;
import com.site.wisdom_construction.responseEntity.FaceRecognitionResult;
import com.site.wisdom_construction.responseEntity.IssueFaceRecognitionResult;
import com.site.wisdom_construction.responseEntity.TwoDataResult;
import com.site.wisdom_construction.util.HttpRequest;
import com.site.wisdom_construction.util.verification.NoToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/** @Author daiyifei @Date 2022/3/12 @Description */
@Api(tags = "人脸识别机")
@RestController
@RequestMapping("FaceRecognition")
@CrossOrigin
@NoToken
public class FaceRecognitionController {

  @ApiOperation(value = "统计数据", notes = "测试数据:")
  @PostMapping("/issueFaceRecognition")
  @NoToken
  public IssueFaceRecognitionResult issueFaceRecognition(@RequestBody Map map) {
    System.out.println("执行了");
    HttpRequest httpRequest = new HttpRequest();
    String base64 ="";

    IssueFaceRecognitionResult issueFaceRecognitionResult = new IssueFaceRecognitionResult();
    issueFaceRecognitionResult.setCmd("upload person");
    issueFaceRecognitionResult.setId("340122199608888888");
    issueFaceRecognitionResult.setKind(0);
    issueFaceRecognitionResult.setRole(1);
    issueFaceRecognitionResult.setReg_image(base64);
    issueFaceRecognitionResult.setName("代逸飞");
    issueFaceRecognitionResult.setTerm_start("2017/11/10 12:00:00");
    issueFaceRecognitionResult.setTerm("2017/12/18 16:45:30");
    return issueFaceRecognitionResult;
  }

//  @ApiOperation(value = "统计数据", notes = "测试数据:")
//  @PostMapping("/insertFaceRecognition")
//  @NoToken
//  public FaceRecognitionResult insertFaceRecognition(@RequestBody Map map) {
//    FaceRecognitionResult faceRecognitionResult = new FaceRecognitionResult();
//    JSONObject json = new JSONObject(map);
//    System.out.println("json:" + json);
//    JSONObject jsonObject = json.getJSONObject("closeup_pic");
//    System.out.println("------------------------------------->");
//    System.out.println("------------------------------------->");
//
//    String base64 = (String) jsonObject.get("data");
//    System.out.println("base64:" + base64);
//    faceRecognitionResult.setReply("ACK");
//    faceRecognitionResult.setCmd("ACK");
//    faceRecognitionResult.setCode(0);
//    faceRecognitionResult.setSequence_no((Integer) json.get("sequence_no"));
//    faceRecognitionResult.setCap_time((String) json.get("cap_time"));
//    JSONObject jsonObject1 = new JSONObject();
//    jsonObject1.put("ctrl_mode", "force");
//    faceRecognitionResult.setGateway_ctrl(jsonObject1);
//    return faceRecognitionResult;
//  }
}
